import Vue from 'vue'
import Vuex from 'vuex'
import { setItem, getItem } from '@/utils/storage'

Vue.use(Vuex)
const TOKEN_KEY = 'USER_TOKEN'
export default new Vuex.Store({
  state: {
    userToken: getItem(TOKEN_KEY),
    goodsList: []
  },
  mutations: {
    setUserToken (state, data) {
      state.userToken = data
      setItem(TOKEN_KEY, state.userToken)
    },
    setGoodsList (state, data) {
      state.goodsList = data
    }
  },
  actions: {},
  modules: {}
})
